﻿<Window x:Class="Wpf2.Views.FormEditExportOrder"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Cập nhật hóa đơn xuất" Height="698.508" Width="Auto" WindowStartupLocation="CenterScreen" WindowState="Maximized">
    <StackPanel Background="#FF3C2AF9" Margin="0,0,0,3" >
        <StackPanel  Grid.Row="1" Margin="5,5,5,5" Height="50" Orientation="Horizontal" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
            <Label Content="HĐ XUẤT" Target="{Binding ElementName=txtUserID}" Background="{x:Null}" Foreground="#FF1E1E1E" FontSize="30" FontWeight="Bold" Width="145"/>
            <Label Margin="5,0,0,0" Height="30" Target="{Binding ElementName=txtUserID}" Content="_Mã NV:" Background="#FF0050EF" Foreground="White"></Label>
            <TextBox Padding="5" x:Name="txtUserID" Height="30" Width="73" Margin="0,10,10,10" Text="{Binding User.ID_USER, UpdateSourceTrigger=PropertyChanged}" PreviewTextInput="TxtAcceptNumbericPreviewTextInput" Background="#FF0050EF" Foreground="#FFFCFCFC"/>
            <Label Height="30" Target="{Binding ElementName=txtCustomer}" Content="_KH:" Background="#FF0050EF" Foreground="White"></Label>
            <TextBox Padding="5" x:Name="txtCustomerName" Height="30" Text="{Binding Customer.CusName, UpdateSourceTrigger=PropertyChanged}" Width="91" Margin="0,10,10,10" Foreground="#FFFCFCFC" Background="#FF0050EF"></TextBox>
            <Label Target="{Binding ElementName=txtAddress}" Height="30" Content="ĐC:" Foreground="White" Background="#FF0050EF"></Label>
            <TextBox Padding="5" x:Name="txtCustomerAddress" Height="30" Text="{Binding Customer.Address, UpdateSourceTrigger=PropertyChanged}" Width="151" Margin="0,10,10,10" Background="#FF0050EF" Foreground="#FFFCFCFC"></TextBox>
            <Label Target="{Binding ElementName=txtPhoneNumber}" Height="30" Content="ĐT:" Background="#FF0050EF" Foreground="White"></Label>
            <TextBox Padding="5" x:Name="txtCustomerPhoneNumber" Text="{Binding Customer.Phone, UpdateSourceTrigger=PropertyChanged}" Height="30" Width="82" PreviewTextInput="TxtAcceptNumbericPreviewTextInput" Foreground="#FFFCFCFC" Background="#FF0050EF" Margin="0,10"></TextBox>
            <StackPanel Margin="10,0,10,0" Width="120" Height="30" Orientation="Horizontal">
                <Button x:Name="btnSaveOrder"  Width="90" Background="#16499A" Command="{Binding SaveOrderCommand}">
                    <TextBlock Foreground="#FFFCFCFC"> Lưu</TextBlock>
                </Button>
                <StackPanel Width="30" Height="30" Background="#FF0050EF">
                    <Image Source="/Wpf2;component/Images/Save.png" />
                </StackPanel>
            </StackPanel>
            <StackPanel Margin="0,0,20,0" Width="120" Height="30" Orientation="Horizontal">
                <Button x:Name="btnPrint"  Width="90" Background="#16499A" Command="{Binding PrintOrderCommand}">
                    <TextBlock Foreground="#FFFCFCFC"> In</TextBlock>
                </Button>
                <StackPanel Width="30" Height="30" Background="#FF0050EF">
                    <Image Source="/Wpf2;component/Images/print.png" />
                </StackPanel>
            </StackPanel>

        </StackPanel>

        <!-- khung edit thong tin cửa hàng -->
        <StackPanel Margin="5,0,5,5" Height="50" Orientation="Horizontal" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
            <StackPanel  Orientation="Horizontal"  DataContext="{Binding StoreInfo}">
                
                <Label Height="30" Content="Tên cửa hàng"></Label>
                <TextBox Name="txtStoreName" Text="{Binding StoreName, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" AcceptsReturn="True" Width="85" Height="20" Margin="0,15" ></TextBox>
                <Label Height="30" Content="Địa chỉ" Margin="0,0,0,0"></Label>
                <TextBox Name="txtAddress" Width="101" Height="20" Text="{Binding Address, UpdateSourceTrigger=PropertyChanged}" Margin="0,15"></TextBox>
                <Label Height="30" Content="Di động" Margin="0,0,0,0"></Label>
                <TextBox Name="txtMobile" Width="69" Height="20" Text="{Binding Mobile, UpdateSourceTrigger=PropertyChanged}" Margin="0,15" ></TextBox>
                <Label Height="30" Content="Điện thoại" Margin="0,0,0,0"></Label>
                <TextBox Name="txtPhone" Width="86" Height="20" Text="{Binding Phone, UpdateSourceTrigger=PropertyChanged}" Margin="0,15"></TextBox>
                
            </StackPanel>
        </StackPanel>
        <DataGrid ItemsSource="{Binding ListProducts}" Grid.Row="2" x:Name="dtgInventory" Background="White" Height="399" AutoGenerateColumns="False" CanUserAddRows="False" Margin="5,0,5,5" AlternatingRowBackground="PaleTurquoise">
            <DataGrid.RowHeaderTemplate>
                <DataTemplate>
                    <TextBlock  Width="20" Text="{Binding Header, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}, Mode=FindAncestor}}"/>
                </DataTemplate>
            </DataGrid.RowHeaderTemplate>
            <DataGrid.Columns>
                <DataGridTemplateColumn Header="Mã SP">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid VerticalAlignment="Bottom" HorizontalAlignment="Center">
                                <TextBox Height="20" Width="50" Text="{Binding ProductId,UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" TextChanged="TxtProductNameTextChanged" LostFocus="TxtProductNameLostFocus" KeyDown="TxtProductNameKeydown" Background="{x:Null}"/>
                                <ComboBox  Visibility="Hidden"  IsTabStop="False" IsSynchronizedWithCurrentItem="True" SelectionChanged="ComboBoxSelectionChanged"></ComboBox>
                            </Grid>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn Header="Tên Sản Phẩm" Width="100" Binding="{Binding ProductName, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True" CanUserSort="False"/>
                <DataGridTextColumn Header="Mô Tả" Binding="{Binding ProductDescription, UpdateSourceTrigger=PropertyChanged}" Width="100" IsReadOnly="True" CanUserSort="False"/>
                <!-- BeginRegion-->
                <!-- DataGird không thể sử dụng elementName => phải dùng Source-->
                <!-- hiện lỗi không sao! cứ bỏ qua-->
                <!-- Xử lý dạng Đá Hoa Cương (9/5/2014)-->
                <DataGridTemplateColumn Header="Dài" Width="50" IsReadOnly="True" CanUserSort="False">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Text="{Binding ProductHeight, UpdateSourceTrigger=LostFocus}" LostFocus="CaculationPayment" TextChanged="txtDaiRong_textChanged" BorderThickness="0"  Background="{x:Null}"></TextBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="Rộng" Width="50" IsReadOnly="True" CanUserSort="False" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Text="{Binding ProductWidth, UpdateSourceTrigger=LostFocus}" LostFocus="CaculationPayment" TextChanged="txtDaiRong_textChanged" BorderThickness="0" Background="{x:Null}"></TextBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <!-- EndRegion-->
                <DataGridTemplateColumn Header="Số Lượng">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Text="{Binding InventoryCount, UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" PreviewTextInput="TxtInventoryCountPreviewTextInput" TextChanged="TxtInvetoryCountTextChanged" Background="{x:Null}"></TextBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <!-- Chức năng Đá Hoa Cương: thêm ngày (9/5/14)-->
                <DataGridTextColumn Header="M2" Binding="{Binding ProductM2, UpdateSourceTrigger=PropertyChanged}" Width="50" IsReadOnly="True" CanUserSort="False"/>
                <DataGridTextColumn Header="Giá" Binding="{Binding Price, UpdateSourceTrigger=PropertyChanged,StringFormat={}\{0:###\,##0\}}" IsReadOnly="True" Width="80" CanUserSort="False"/>
                <DataGridTemplateColumn Header="Giá sỉ">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox IsChecked="{Binding IsCostPrice, UpdateSourceTrigger=PropertyChanged}" Checked="chboxIsCostPrice_checked" Unchecked="chboxIsCostPrice_checked"></CheckBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn Header="Đơn Vị" Binding="{Binding UnitName, UpdateSourceTrigger=PropertyChanged}" Width="80" IsReadOnly="True" CanUserSort="False"/>
                <DataGridTextColumn Header="Nhóm" Binding="{Binding CatalogName, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True" Width="80" CanUserSort="False"/>
                <DataGridTextColumn Header="Thành tiền" Binding="{Binding TotalOutPayment, UpdateSourceTrigger=PropertyChanged,StringFormat={}\{0:###\,##0\}}" IsReadOnly="False" Width="*" CanUserSort="False"/>
            </DataGrid.Columns>
        </DataGrid>
            <StackPanel  DataContext="{Binding Payment}" Height="130" x:Name="panelOfPaymentInfomation" Background="#FFF6F6F6" Grid.ColumnSpan="2" Margin="5,5,5,5">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" >
                    <StackPanel Margin="0,10,5,5" HorizontalAlignment="Right">
                        <WrapPanel  Margin="0,0,0,10">
                            <Label Width="80" Height="30" Target="{Binding ElementName=txtOLD_DEBTS}" Content="_Nợ cũ:" Background="#FF0050EF" Foreground="White" ></Label>
                            <TextBox Padding="5" x:Name="txtOLD_DEBTS" Text="{Binding OldDebts, UpdateSourceTrigger=PropertyChanged,StringFormat={}\{0:###\,##0\}}" TextAlignment="Right" Height="30" Width="130"  PreviewTextInput="TxtAcceptNumbericPreviewTextInput" Background="#FF0050EF" Foreground="White"/>
                        </WrapPanel>
                        <WrapPanel HorizontalAlignment="Right" >
                            <Label Width="80" Target="{Binding ElementName=txtPRE_PAID}" Content="_Gửi trước:" Background="#FF0050EF" Foreground="White"></Label>
                            <TextBox Padding="5" x:Name="txtPRE_PAID" Text="{Binding PrePaid, UpdateSourceTrigger=PropertyChanged,StringFormat={}\{0:###\,##0\}}" TextAlignment="Right" Height="30" Width="130"  PreviewTextInput="TxtAcceptNumbericPreviewTextInput" Foreground="#FFFCFCFC" Background="#FF0050EF"></TextBox>
                        </WrapPanel>
                    </StackPanel>
                    <StackPanel Margin="5,10,5,5" HorizontalAlignment="Right">
                        <WrapPanel HorizontalAlignment="Right" Margin="0,0,0,10">
                            <Label Width="80" Height="30" Target="{Binding ElementName=txtSumOut}" Content="Tổng t_oa:" Background="#FF0050EF" Foreground="White" ></Label>
                            <TextBox Padding="5" x:Name="txtSumOut" IsEnabled="False" Text="{Binding SumOut, UpdateSourceTrigger=PropertyChanged,StringFormat={}\{0:###\,##0\} VNĐ}" TextAlignment="Right" Height="30" Width="130"  PreviewTextInput="TxtAcceptNumbericPreviewTextInput" Background="#FF0050EF" Foreground="#FFFCFCFC"></TextBox>
                        </WrapPanel>
                        <WrapPanel HorizontalAlignment="Right" Margin="0,0,0,10">
                            <Label Width="80" Height="30" Target="{Binding ElementName=txtTotal}" Content="Tổn_g cộng:" Background="#FF0050EF" Foreground="White"></Label>
                            <TextBox Padding="5" x:Name="txtTotal" IsEnabled="False" Text="{Binding TotalPayment, UpdateSourceTrigger=PropertyChanged,StringFormat={}\{0:###\,##0\} VNĐ}" TextAlignment="Right" Height="30" Width="130" PreviewTextInput="TxtAcceptNumbericPreviewTextInput" Background="#FF0050EF" Foreground="#FFFCFCFC"></TextBox>
                        </WrapPanel>
                        <WrapPanel HorizontalAlignment="Right">
                            <Label Width="80" Height="30" Target="{Binding ElementName=txtRemain}" Content="Còn _lại:" Background="#FF0050EF" Foreground="White"></Label>
                            <TextBox Padding="5" x:Name="txtRemain" IsEnabled="False" Text="{Binding Remain, UpdateSourceTrigger=PropertyChanged,StringFormat={}\{0:###\,##0\} VNĐ}" TextAlignment="Right" Height="30" Width="130" PreviewTextInput="TxtAcceptNumbericPreviewTextInput" Background="#FF0050EF" Foreground="#FFFCFCFC"></TextBox>
                        </WrapPanel>
                    </StackPanel>
                </StackPanel>

            </StackPanel>
         

           
       
    </StackPanel>
</Window>
